/**
 * 创意相关api
 */
angular.module('imsApp').factory('CreativesManager', ['$http','api', 'paramsManager', function ($http,api, paramsManager) {
    var CreativesManager = {
        /**
         * 创意列表
         params:[pageNo,pageSize]//顺序不能错
         */
        creativesList: function (groupId, params) {
            return $http.get(api+'/ims/groups/'+groupId+'/creatives/' + paramsManager.params(params)).then(function (result) {
                return result;
            });
        },
        /**
         * 创意添加
         * @param params
         * @returns
         */
        creativesAdd: function (groupId,params) {
            return $http.post(api+'/ims/groups/'+groupId+'/creatives', params).then(function (result) {
                return result;
            });
        },
        /**
         * 创意详情
         * @param creativeId
         * @returns
         */
        creativesDetail: function (creativeId) {
            return $http.get(api+'/ims/creatives/'+creativeId).then(function (result) {
                return result;
            });
        },
        /**
         *创意修改
         * @param creativeId
         */
        creativesEdit: function (creativeId,params) {
            return $http.put(api+'/ims/creatives/'+creativeId,params).then(function (result) {
                return result;
            });
        },/**
         *创意删除
         * @param ids [];
         */
        creativesDelete: function (ids) {
            return $http.delete(api+'/ims/creatives/'+ids.join(",")).then(function (result) {
                return result;
            });
        },

        /**
         *创意修改状态
         * @param params {status:11}
         * @returns {"c":"f"} ?{"c": "f","i":"修改失败"}
         */
        creativesStatusEdit: function (creativeId,params) {
            return $http.put(api+'/ims/creatives/'+creativeId+'/status',params).then(function (result) {
                return result;
            });
        },
        /**
         *创意文件上传
         * @param params type:photo/video/audio
         * @returns {"c":"f"} ?{"c": "f","i":"修改失败"}
         */
        creativesFileUpload: function (type,params) {
            return $http.put(api+'/ims/creatives/'+type,params).then(function (result) {
                return result;
            });
        },




    };


    return CreativesManager;
}]);
